package org.chenbingkang.jmapper;

import com.googlecode.jmapper.JMapper;
import org.chenbingkang.modelmapper.Address;
import org.chenbingkang.modelmapper.Customer;
import org.chenbingkang.modelmapper.Name;
import org.chenbingkang.modelmapper.Order;
import org.chenbingkang.modelmapper.OrderDTO;
import org.modelmapper.ModelMapper;

import java.util.HashMap;
import java.util.Map;

public class Application {
    public static void main(String... args) {
        org.chenbingkang.modelmapper.Name name = new Name();
        name.setFirstName("李");
        name.setLastName("四");
        org.chenbingkang.modelmapper.Address address = new Address();
        address.setCity("长沙市");
        address.setStreet("岳麓大道");

        org.chenbingkang.modelmapper.Customer customer = new Customer();
        customer.setName(name);

        org.chenbingkang.modelmapper.Order order = new Order();
        order.setCustomer(customer);
        order.setBillingAddress(address);

        System.out.println(order);

        ModelMapper modelMapper = new ModelMapper();

        HashMap<String, Object> sourceMap = new HashMap<>();
        sourceMap.put("customerFirstName", "李");
        sourceMap.put("customerLastName", "四");
        sourceMap.put("billingStreet", "岳麓大道");
        sourceMap.put("billingCity", "长沙市");


        HashMap<String, Object> sourceMap3 = new HashMap<>();
        sourceMap3.put("firstName", "李");
        sourceMap3.put("lastName", "四");
        Map<String, Object> sourceMap4 = new HashMap<>();
        sourceMap4.put("street", "岳麓大道");
        sourceMap4.put("city", "长沙市");

        Map<String, Object> sourceMap2 = new HashMap<>();
        sourceMap.put("customer", sourceMap3);


        JMapper<OrderDTO, HashMap> userMapper = new JMapper<>(
                OrderDTO.class, HashMap.class);
        OrderDTO result = userMapper.getDestination(sourceMap);
        System.out.println(result);
    }
}
